package org.gnyxy.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.gnyxy.dto.AdminNotPasswordDTO;
import org.gnyxy.dto.AdminPageQueryDTO;
import org.gnyxy.entity.Admin;
import org.gnyxy.vo.AdminSelectVO;

@Mapper
public interface AdminMapper {
    @Select("select * from admin where deleted = 0 and name = #{name}")
    Admin getByName(String name);

    @Insert("insert into admin (name, password, create_time, update_time, deleted) values " +
            " (#{name},#{password},#{createTime},#{updateTime},#{deleted})")
    void add(Admin admin);

    Page<AdminSelectVO> pageQuery(AdminPageQueryDTO adminPageQueryDTO);

    @Update("update admin set name = #{name} ,update_time = #{updateTime} where id = #{id}")
    void update(Admin admin);

    @Select("select * from admin where deleted = 0 and id = #{id}")
    Admin getById(Long id);

    @Update("update admin set deleted = 1 where id = #{id}")
    void delete(Long id);

    @Update("update admin set password = #{password} where id = #{id}")
    void updatePassword(String password,Long id);
}
